package com.qyhl.module_home.home.search;


import com.qyhl.webtv.commonlib.entity.home.NewsBean;

import java.util.List;

/**
 * Created by qyhl on 2017/11/17.
 */

public class SearchPresenter implements SearchContract.SearchPresenter {
    private SearchModel mModel;
    private SearchContract.SearchView mView;

    public SearchPresenter(SearchContract.SearchView mView) {
        this.mView = mView;
        this.mModel = new SearchModel(this);
    }

    @Override
    public void setError(int code, String msg) {
        switch (code) {
            case 1:
                mView.setNetError(msg);
                break;
            case 2:
                mView.showError(msg);
                break;
            case 3:
                mView.setEmpty(msg);
                break;
            case 4:
                mView.showMessage(msg);
                break;
            default:
                break;
        }
    }

    /**
     * 设置搜索数据
     *
     * @param beanList
     * @param isMore
     */
    @Override
    public void setData(List<NewsBean> beanList, boolean isMore) {
        mView.setData(beanList, isMore);
    }

    /**
     * 获取搜索数据
     *
     * @param keyword
     * @param newsId
     */
    @Override
    public void getData(String keyword, String newsId) {
        mModel.getData(keyword, newsId);
    }

    @Override
    public void getList(String keyword, String newsId, String catalogId, int subCatalog) {
        mModel.getList(keyword, newsId, catalogId, subCatalog);
    }
}
